package myself.doit.schedule.v1;

import java.lang.reflect.Method;
import java.util.Date;

/**
 * Created by bjliuyong on 2017/1/10.
 */
public class SchedulerMain03 {

    public static void main(String args[]) throws Exception {

        SchedulerMain03 schedulerMain = new SchedulerMain03() ;
        Method method1 = schedulerMain.getClass().getMethod("echo1");
        Method method2 = schedulerMain.getClass().getMethod("echo2");

        CronTask cronTask01 = new CronTask(new ScheduledMethodRunnable(schedulerMain , method1) , "0/1 * * * * ?");
        CronTask cronTask02 = new CronTask(new ScheduledMethodRunnable(schedulerMain , method2) , "0/1 * * * * ?");

        cronTask01.start();
        cronTask02.start();

        cronTask01.join();
        cronTask02.join();

    }


    public void echo1() {
        System.out.println("this is SchedulerMain03 " + CronSequenceGenerator.format(new Date()));
    }


    public void echo2() {
        System.out.println("this is SchedulerMain03 " + CronSequenceGenerator.format(new Date()));
    }

}
